package gee

import (
	"net/http"
)

type router struct {
	handlers map[string]HandlerFunc
}

func newRouter() *router {
	return &router{handlers: make(map[string]HandlerFunc)}
}

func (r *router) addRoute(method,pattern string,handler HandlerFunc)  {
	key := method + "-" + pattern
	r.handlers[key] = handler
}

func (r *router) handle(c *Context)  {
	key := c.Method + "-" + c.Path
	if handler,ok := r.handlers[key];ok{
		c.handlers = append(c.handlers,handler)
	}else {
		c.String(http.StatusNotFound,"404 NOT Found %s \n",c.Path)
	}

	c.Next()
}
